import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import NotFound from '../views/NotFound.vue';
import Home from '../views/Home.vue';
import UserManagement from '../views/UserManagement.vue';
import SystemSettings from '../views/SystemSettings.vue';
import Dashboard from '../views/Dashboard.vue';

const routes = [
  { path: '/', redirect: '/dashboard' },
  { 
    path: '/dashboard',
    name: 'Dashboard',
    component: Dashboard,
    children: [
      {
        path: '', // 默认子路由，等价于 /dashboard
        name: 'Home',
        component: Home,
      },
      {
        path: 'home', // /dashboard/home
        name: 'Home',
        component: Home,
      },
      {
        path: 'user-management', // /dashboard/user-management
        name: 'UserManagement',
        component: UserManagement,
      },
      {
        path: 'system-settings', // /dashboard/system-settings
        name: 'SystemSettings',
        component: SystemSettings,
      },
    ],
  },
  { path: '/login', name: 'Login', component: Login },
  { path: '/register', name: 'Register', component: Register },
  {
    path: '/:pathMatch(.*)*', // Catch-all route
    name: 'NotFound',
    component: NotFound,
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router; 